<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of TimeZoneObject
 *
 * @author jian.li
 */
class Tools_TimeZoneObject extends Erra_Fields_Base_Object {

    public static function initTimeZone() {
        $timezone_identifiers = DateTimeZone::listIdentifiers();
        $currentTimeZone = Config_GeneralConfigObject::get('fuseau_horaire');
        if(in_array($currentTimeZone, $timezone_identifiers)) {
            date_default_timezone_set($currentTimeZone);
        }
    }
    public static function makeTimeZoneList($englobe) {
 
        $query = 'SELECT fuseau_horaire FROM config_generalconfigobject';
        $result = Erra_Core_DatabasePdo::SELECT($query);
        if (Erra_Core_DatabasePdo::rowCount() && is_object($result)) {
            $row = $result->fetch();
            
            $timezone_identifiers = DateTimeZone::listIdentifiers();
            for ($i = 0; $i < count($timezone_identifiers); $i++) {

                echo "<$englobe";
                if ($row->fuseau_horaire == $timezone_identifiers[$i]) {
                    echo " selected ";
                }
                echo ">" . "$timezone_identifiers[$i]" . "</$englobe>";
            }
        }
    }

}

?>
